home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9441 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: news.halcyon.com!usenet
  2. From: normanb@halcyon.com (Norm Bryar)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Need Unique ID generation
  5. Date: Fri, 01 Mar 1996 17:12:27 GMT
  6. Organization: Northwest Nexus Inc.
  7. Message-ID: <4h7b4k$837@news.halcyon.com>
  8. References: <4h3vmq$4a6@alpha.it.net> <31369697.249D@symantec.com>
  9. NNTP-Posting-Host: blv-pm10-ip9.halcyon.com
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. Walter Bright <wbright@symantec.com> wrote:
  13.  
  14. >Antonio Romeo wrote:
  15. >> I need a Unique Identifier generation routine on multiple machines.
  16. >> The identifier must be a 32bit long (unsigned long int) number.
  17.  
  18. >I believe Microsoft solved this problem by melding in the network card 
  19. >address with the time of day.
  20.  
  21. Yes, they did.  GUIDs.  These are 128-bit structs practically certain
  22. to be unique.  
  23.  
  24. To create them programatically, look up
  25.  
  26. CoInitialize()
  27. CoCreateGuid()
  28.  
  29. You can also generate them off-line with the guidgen.exe
  30. then use them in your programs.  To use GUIDs made before-hand, lookup
  31.  
  32. DEFINE_GUID()   // a macro in basetyps.h?
  33.  
  34. Because they're structs, DEFINE_GUID has two flavors, one declares a
  35. variable of the GUID type, the other defines the variable and
  36. initializes the structure with all the values.  You need to #define
  37. INITGUID before the DEFINE_GUIDs and, I think, #include<initguid.h>
  38. together in one and only one of the source-files of your project.  
  39.  
  40. Hope this helps.
  41.                     --Norm 
  42.  
  43.